﻿/*  PandoraUnleashed
    An open source API for the Pandora music service
    Copyright © 2011 Saulius Milevicius

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PandoraUnleashed.Data
{
    class UserData
    {
        public String videoAdUrl { get; set; }
        public int age { get; set; }
        public int maxStationsAllowed { get; set; }
        public Boolean subscriptionHasExpired { get; set; }
        public Boolean canListen { get; set; }
        public String createStationAdUrl { get; set; }
        public String gender { get; set; }
        public String initialNowPlayingAdUrl { get; set; }
        public Boolean isAdSupported { get; set; }
        public String pandoraOneUpgradeInfo { get; set; }
        public String pandoraOneUpgradeUrl { get; set; }
        public String pandoraOneRenewalUrl { get; set; }
        public String splashScreenAdUrl { get; set; }
        public String userAuthToken { get; set; }
        public String userId { get; set; }
        public String username { get; set; }
        public String zip { get; set; }
        public String userProfileUrl { get; set; }
        public int minimumAdRefreshInterval { get; set; }

        /// <summary>
        /// Default constructor for user data
        /// </summary>
        /// <param name="canListen">Can the user listen to Pandora</param>
        /// <param name="isAdSupported">Are ads supported for the user</param>
        /// <param name="userAuthToken">The users auth token</param>
        /// <param name="username">The users username(email)</param>
        /// <param name="userId">The users user id</param>
        /// <param name="splashScreenAdUrl">Splash screen ad url</param>
        /// <param name="createStationAdUrl">Create station ad url</param>
        /// <param name="videoAdUrl">Video ad url</param>
        /// <param name="pandoraOneUpgradeUrl">Pandora One upgrade url</param>
        /// <param name="pandoraOneUpgradeInfo">Pandora One upgrade info</param>
        /// <param name="age">Users age</param>
        /// <param name="gender">Users gender</param>
        /// <param name="zip">Users zip code</param>
        public UserData(Boolean canListen, Boolean isAdSupported, String userAuthToken, String username, String userId, String splashScreenAdUrl, String createStationAdUrl, String videoAdUrl, String pandoraOneUpgradeUrl, String pandoraOneUpgradeInfo, int age, String gender, String zip)
        {
            this.canListen = canListen;
            this.isAdSupported = isAdSupported;
            this.userAuthToken = userAuthToken;
            this.username = username;
            this.userId = userId;
            this.splashScreenAdUrl = splashScreenAdUrl;
            this.createStationAdUrl = createStationAdUrl;
            this.videoAdUrl = videoAdUrl;
            this.pandoraOneUpgradeUrl = pandoraOneUpgradeUrl;
            this.pandoraOneUpgradeInfo = pandoraOneUpgradeInfo;
            this.age = age;
            this.gender = gender;
            this.zip = zip;
        }

        /// <summary>
        /// Create an instance of UserData from a hashtable of json params
        /// </summary>
        /// <param name="json">Hashtable of json params</param>
        public UserData(Hashtable json)
        {
            this.canListen = (Boolean)json["canListen"];
            this.isAdSupported = (Boolean)json["hasAudioAds"];
            this.userAuthToken = (String)json["userAuthToken"];
            this.username = (String)json["username"];
            this.userId = (String)json["userId"];
            this.splashScreenAdUrl = (json.ContainsKey("splashScreenAdUrl")) ? (String)json["splashScreenAdUrl"] : "";
            this.createStationAdUrl = (json.ContainsKey("stationCreationAdUrl")) ? (String)json["stationCreationAdUrl"] : "";

            this.videoAdUrl = (json.ContainsKey("videoAdUrl")) ? (String)json["videoAdUrl"] : "";
            this.userProfileUrl = (json.ContainsKey("userProfileUrl")) ? (String)json["userProfileUrl"] : "";
            this.maxStationsAllowed = (json.ContainsKey("maxStationsAllowed")) ? (int)(double)json["maxStationsAllowed"] : -1;
            this.minimumAdRefreshInterval = (json.ContainsKey("minimumAdRefreshInterval")) ? (int)(double)json["minimumAdRefreshInterval"] : -1;
            this.subscriptionHasExpired = (json.ContainsKey("subscriptionHasExpired")) ? (Boolean)json["subscriptionHasExpired"] : false;
            this.pandoraOneUpgradeUrl = (json.ContainsKey("pandoraOneUpgradeUrl")) ? (String)json["pandoraOneUpgradeUrl"] : "";
            this.pandoraOneUpgradeInfo = (json.ContainsKey("pandoraOneUpgradeInfo")) ? (String)json["pandoraOneUpgradeInfo"] : "";
            this.pandoraOneRenewalUrl = (json.ContainsKey("pandoraOneRenewalUrl")) ? (String)json["pandoraOneRenewalUrl"] : "";
            this.initialNowPlayingAdUrl = (json.ContainsKey("initialNowPlayingAdUrl")) ? (String)json["initialNowPlayingAdUrl"] : "";
            this.age = (json.ContainsKey("age")) ? (int)(double)json["age"] : -1;
            this.gender = (json.ContainsKey("gender")) ? (String)json["gender"] : "";
            this.zip = (json.ContainsKey("zip")) ? (String)json["zip"] : "";
        }
    }
}
